#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include "totalpoint.h"
#include <QPainter>
#include <QString>
#include <QTcpSocket>
#include <QMouseEvent>

namespace Ui {
class MainWindow;
}

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    explicit MainWindow(QWidget *parent = 0);
    ~MainWindow();

    //是否为先手玩家
    bool firstPlayer;

    //判断胜利函数
    bool winner(int posX, int posY, int TheColor);

    QTcpSocket *tcpClient;//客户端tcp socket

    QString message;

    quint16 blockSize;//16位无符号整形

    int mask;

    int color;

    int runState;//游戏状态 running/stopped

    int whoDo;//判断落子方

    Tpoint sendPt;

    myPoint** myPt;

    myPoint* tempPt;

    myPoint* lastPtBlack;

    myPoint* lastPtWhite;

    QString serAddr;//服务器主机ip地址

    int serPort;//服务器之际端口号

    void paintEvent(QPaintEvent *);
    void mouseReleaseEvent(QMouseEvent *);//鼠标事件

signals:
    /*客户端连接服务器信号*/
    void connectToServer();

private slots:
    void logIn();//登入服务器
    int startPre();//玩家已准备开始游戏
    int quitGame();
    int huiQi();
    //int renShu();
    void newConnect();
    void readMessage();
    void displayError(QAbstractSocket::SocketError);

private:
    Ui::MainWindow *ui;

};

#endif // MAINWINDOW_H
